$(function () {
    var addUrl = '/order/addOrder';

    $('#subOrder').click(function () {
        //获取表单内容
        var customerName = $('#customerName').val();//客户名称
        var phone = $('#phone').val();//客户手机号
        var carNum = $('#carNum').val();//订购的车辆数
        var carId = $('#carId').val();
        var totalPrice = $('#totalMoney').val();//总金额
        var status = $('#status').val();//下单状态
        var employName = $('#employName').val();//负责该单的员工名称
        if (customerName == '' || phone == '' ||  carId == '' ||
            carNum == '' || totalPrice == '' || status == '' || employName == '') {
            alert("填写的信息不全");
        }else {
            var order = {};
            var employee = {};
            var customer = {};
            customer.customerName = customerName;
            customer.phone = phone;
            employee.employName = employName;
            employee.status = '1';
            order.carId = carId;
            order.carNum = carNum;
            order.totalPrice = totalPrice;
            order.status = status;
            order.customer = customer;
            order.employee = employee;
            var format = new FormData();
            format.append('orderStr',JSON.stringify(order));
            $.ajax({
                url:addUrl,
                type:"POST",
                data:format,
                contentType:false,
                processData:false,
                cache:false,
                success:function (data){
                    alert(data.message);
                    if (data.code==200){
                        //添加成功
                    }
                }
            })
        }
    })

});